package com.husd.framework.util;

import org.apache.commons.codec.binary.Base64;

/**
 * @author hushengdong
 */
public class Base64Util {

    //base64 解码
    public static String decode(byte[] bytes) {
        return new String(Base64.decodeBase64(bytes));
    }

    //base64 编码
    public static String encode(byte[] bytes) {
        return new String(Base64.encodeBase64(bytes));
    }

    public static void main(String[] args) {
        String string = "test 123";
        String encode = encode(string.getBytes());
        System.out.println(string + " 编码后的字符串为：" + encode);
        String decode = decode(encode.getBytes());
        System.out.println(encode + " 字符串解码后为：" + decode);
    }
}
